

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

public class Question implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	public static final int MAX_PRIORITY = 5;
	public static final int MIN_PRIORITY = 0;
	
	private String strQuestionID;
	private String strQuestion;
	private LinkedHashMap<String, String> mapAnswers;
	private String strChosenAnswerID;
	
	private int priority;
	
	public Question(String strQID, String strQuestion, LinkedHashMap<String, String> arrayAnswers) {
		this.strQuestionID = strQID;
		this.strQuestion = strQuestion;
		this.mapAnswers = new LinkedHashMap<>();
		this.mapAnswers = arrayAnswers;
		
	}
	
	public String getQuestion(){
		return this.strQuestion;
	}
	
	public ArrayList<String> getAnswers(){
		ArrayList<String> answers = new ArrayList<String>();
		for(Entry<String, String> e : this.mapAnswers.entrySet()){
			answers.add(e.getValue());
		}
		return answers;
	}
	
	public void setChosenAnswer(String answer){
		for(Entry<String, String> e : this.mapAnswers.entrySet()){
			if(answer.equals(e.getValue())){
				this.strChosenAnswerID = e.getKey();
			}
		}
	}
	
	String getChosenAnswerID(){
		return this.strChosenAnswerID;
	}
	
	String getQuestionID(){
		return this.strQuestionID;
	}
	
	boolean setPriority(int priority){
		if(priority<= MAX_PRIORITY && priority>= MIN_PRIORITY){
			this.priority = priority;
			return true;
		}
		return false;
	}
	
	int getPriority(){
		return this.priority;
	}
}
